package org.nudt.common.repository;

import org.nudt.common.model.PlayLog
import org.nudt.common.model.vo.PlayLogVO
import org.springframework.data.domain.Page
import org.springframework.data.domain.Pageable
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Query

interface PlayLogRepository : JpaRepository<PlayLog, Int> {
    
    
    @Query(
        value = "select a.id,a.appid,b.id as video_id,b.video_name,b.cover_url,b.blurb,a.created_at,a.updated_at from play_log a,video b where a.video_id = b.id and a.appid = ?1 order by a.id desc",
        nativeQuery = true
    )
    fun getPlayLogListByAppid(appid: String, pageable: Pageable): Page<PlayLogVO>
    
    
    @Query(
        value = "select a.id,a.appid,b.id as video_id,b.video_name,b.cover_url,b.blurb,a.created_at,a.updated_at from play_log a,video b where a.video_id = b.id order by a.id desc",
        nativeQuery = true
    )
    fun getPlayLogList(pageable: Pageable): Page<PlayLogVO>
}